package com.example.robertluozizhao.framecollectdemo.common;

import android.app.Application;
import android.text.TextUtils;
import android.util.Log;

import com.example.robertluozizhao.framecollectdemo.util.AppUtils;
import com.example.robertluozizhao.framecollectdemo.util.SDcardUtils;
import com.squareup.leakcanary.LeakCanary;


import java.io.File;
import java.io.IOException;
import java.util.List;

/**
 * Created by robert.luozizhao on 2018/1/31.
 */

public class FrameApplication extends Application {

    private final static String TAG = "LeakCanaryApplication";


    @Override
    public void onCreate() {
        super.onCreate();
        if (!AppUtils.isMainProcess(this)) {
            return;
        }
        LeakCanary.install(this);

        String sdCardPath = SDcardUtils.getSDCardPath();
        Log.d(TAG, "onCreate: sdCardPath:" + sdCardPath.trim());


//        createFile();
    }

    private void createFile() {
        String folder = SDcardUtils.getSDCardPath() + "/student/class1/";
        if (!new File(folder).exists()) {
            boolean mkdirs = new File(folder).mkdirs();
            Log.d(TAG, "createFile: "+" folder:"+folder+",文件夹创建成功！！");

            String file = folder+"/liming.txt";
            if (!new File(file).exists()) {
                try {
                    boolean newFile = new File(file).createNewFile();
                    Log.d(TAG, "createFile: "+"newFile:"+newFile+",文件创建成功！！");
                } catch (IOException e) {
                    Log.e(TAG, "createFile: "+"makeFalseData error:"+e.getMessage());
                    e.printStackTrace();
                }
            }
        }
    }
}
